package com.food.platformmsgmanagement.adapter.inbound;

import com.food.platformmsgmanagement.domain.Aliment;
import com.food.platformmsgmanagement.domain.Comment;
import com.food.platformmsgmanagement.domain.Status;
import com.food.platformmsgmanagement.port.inbound.AlimentUseCase;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 24270
 */
@RestController
@RequestMapping(value = "/aliment")
@CrossOrigin("*")
public class AlimentController {
    private final AlimentUseCase useCase;

    @Autowired
    public AlimentController(AlimentUseCase useCase) {
        this.useCase = useCase;
    }

    @GetMapping("/getAll")
    public List<AlimentDTO> getAllAliment() {
        return useCase.getAllAliment();
    }

    @GetMapping("/getOne/{id}")
    public AlimentDTO getTheAliment(@PathVariable String id) {
        return this.useCase.getTheAliment(id);
    }

    @PostMapping("/add/{title}/{mainText}")
    public String addAliment(@PathVariable String title, @PathVariable String mainText) {
        return useCase.addAliment(title, mainText);
    }

    @PostMapping("/addImg")
    public void addImg(@RequestParam String id, @RequestParam List<String> imgUrl) {
        useCase.addAlimentImg(id, imgUrl);
    }

    @PostMapping("/changeStatus/{id}/{status}")
    public void changeStatus(@PathVariable String id, @PathVariable String status) {
        useCase.changeAlimentStatus(id, status);
    }

    @PostMapping("/delete/{id}")
    public boolean deleteAliment(@PathVariable String id) {
        return useCase.deleteAliment(id);
    }

}